package com.definesys.smecrailtransit.module.LineReport;

import android.content.Context;

import com.definesys.smecrailtransit.SmecManager.SmecRetrofit.BaseSubscriber;
import com.definesys.smecrailtransit.SmecManager.SmecRetrofit.HttpResult;
import com.definesys.smecrailtransit.base.SmecBasePresenter;
import com.definesys.smecrailtransit.module.LineReport.bean.LineReportBean;

import java.util.HashMap;

import rx.Observable;

/**
 * Created by cjy on 2018/1/3.
 */

public class LineReportPresenter extends SmecBasePresenter implements LineReportContract{

    public LineReportPresenter(Context mContext) {
        super(mContext);
    }

    @Override
    public void getLineReport(HashMap<String, Object> map) {
        Observable<HttpResult<LineReportBean>> observable = smecRailService.lineReport(map);
        schedulerThread(observable).subscribe(new BaseSubscriber<HttpResult<LineReportBean>>() {
            @Override
            public void onNext(HttpResult<LineReportBean> t) {
                LineReportBean data = t.getData();
                mRxbus.post(LineReportFragment.LINE_REPORT_SUCCESS,data);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                mRxbus.post(LineReportFragment.LINE_REPORT_ERROR,new Object());
            }
        });
    }
}
